import cv2


def check_image_containment(image1_path, image2_path):
    # 读取两张图片
    image1 = cv2.imread(image1_path)
    image2 = cv2.imread(image2_path)

    # 将图片转换为灰度图
    gray1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
    gray2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY)

    # 使用模板匹配方法进行图像匹配
    result = cv2.matchTemplate(gray1, gray2, cv2.TM_CCOEFF_NORMED)

    # 获取匹配结果的最大值和对应的位置
    _, max_val, _, max_loc = cv2.minMaxLoc(result)

    # 判断最大匹配值是否大于阈值
    threshold = 0.8
    if max_val >= threshold:
        print("两张图片有包含关系")
    else:
        print("两张图片没有包含关系")


# 调用函数进行图片匹配
check_image_containment("image1.jpg", "image2.jpg")